package exception_test;

import java.util.Scanner;

public class MyExceptionTest {
    private static final String USER_NAME = "风眼";
    private static final String PASSWORD = "xianglong";

    public static void main(String[] args) {
        Scanner scanner =new Scanner(System.in);
        System.out.println("请输入用户名");
        String username = scanner.nextLine();
        System.out.println("请输入密码");
        String pass = scanner.nextLine();
        if (!USER_NAME.equals(username)){
            //用户名错误异常
            throw new UserNmerException("用户名错误");
        }
        if (!PASSWORD.equals(pass)){
            //密码错误异常
            throw  new PassWoreEXception("密码错误");
        }
    }
}
class UserNmerException extends RuntimeException{
    public UserNmerException(String msg){
        super(msg);
    }
}
class PassWoreEXception extends RuntimeException{
    public PassWoreEXception(String msg){
        super(msg);
    }
}
